package com.haiyou.dc.aggregate.list;

import java.util.Arrays;

/**
 * 扩容实现
 * 默认长度为10，元素数量超过10个，长度增加一半
 * 使用Arrays.copyOf进行拷贝，再指向原来数组
 */
public class TestArrayList02 {

    public static void main(String[] args) {


        String[] arr01 = new String[4];
        arr01[0] = "a";
        arr01[1] = "b";
        arr01[2] = "c";
        arr01[3] = "d";
        System.out.println(Arrays.toString(arr01));

        int size=arr01.length;
        int index=1;
        int numMoved = size - index - 1;
        System.arraycopy(arr01, index+1, arr01, index, numMoved);
        arr01[--size] = null;

        System.out.println(Arrays.toString(arr01));

//        String[] strings = Arrays.copyOf(arr01, 5);
//        System.out.println(Arrays.toString(strings));

//        List<Integer> list01 = new ArrayList<>();
//        list01.addAll(Arrays.asList(1, 2, 3, 5, 6, 7, 8));
//        System.out.println(list01);
//
//        list01.remove(2);
//        System.out.println(list01);


    }
}
